package com.hypo.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Slf4j
//@Component
//@Aspect
public class MyAspect2 {
    //针对DeptServiceImpl中findAll()方法前后执行前置通知和后置通知

    //前置通知
    @Before("@annotation(com.hypo.annotation.LogOperation)")
    public void before(JoinPoint jp){
        String name = jp.getSignature().getName();
        log.info("MyAspect2前置通知{} -> before ...",name);
    }

    //后置通知
    @After("@annotation(com.hypo.annotation.LogOperation)")
    public void after(JoinPoint jp){
        String name = jp.getSignature().getName();
        log.info("MyAspect2后置通知 {} -> after ...",name);
    }
}
